import { Column, Entity, JoinColumn, JoinTable, ManyToMany, OneToOne, PrimaryGeneratedColumn } from 'typeorm';
import { IsNotEmpty } from 'class-validator';
import { Profile } from './profile.entity';
import { Roles } from 'src/roles/modules/roles.entity';

@Entity('user')
export class User {
  @PrimaryGeneratedColumn('uuid')
  id: string;

  @Column({ comment: '用户名', default: '' })
  @IsNotEmpty()
  username: string;

  @Column({ comment: '密码', nullable: true })
  password: string;

  @Column({ comment: '账户信息', nullable: true })
  account: string;

  @Column({ comment: '验证码生成时间', nullable: true })
  createTimeAt: Date;

  @ManyToMany(() => Roles, roles => roles.users)
  @JoinTable({ name: 'users_roles' })
  roles: Roles[];

  @OneToOne(() => Profile, profile => profile.user)
  profile: Profile;
}
